﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SalesInvoice.aspx.cs" Inherits="Main_ServiceInvoice_SalesInvoice"
    Culture="en-GB" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title><B>Sale Invoice</B></title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />


    <script type="text/javascript">

        function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode > 47))
                return false;

            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }
        function EnabledTabKey(id, e) {
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key                
                return true;
            }
            else {
                return false;
            }
        }
        function GetLastNumber(str) {
            for (var i = 0; i < str.length; i++) {
                if (!isNaN(str.charAt(i))) {
                    str = str.substring(str.indexOf(str.charAt(i)));
                    break;
                }
            }
            var rgx = new RegExp("[a-zA-Z]");
            if (rgx.test(str)) {
                str = str.substring(1);
                return (GetLastNumber(str));
            }
            else {
                return str;
            }
        }
        //        function GetLastNumber(sText) {
        //            var Char;
        //            var nextChar;
        //            var lastRow = 0;
        //            var pat='[a-z]';
        //            for (i = 0; i < sText.length; i++) {
        //                Char = sText.charAt(i);
        //                //nextChar=sText.charAt(i+1 && i<=sText.length);
        //                if (!isNaN(parseFloat(Char))) {
        //                    lastRow = sText.toString().substr(i);
        //                    break;
        //                }
        //            }
        //            var patt1=new RegExp("[a-z]");
        //            if(patt1.test(lastRow))
        //            {
        //              var dd=lastRow;
        //              var rr=dd.substring(1);
        //              alert(rr);
        //               //GetLastNumber(dd);
        //            }
        //           
        //            return lastRow;
        //            
        //        }
        function ValidateRequired(id) {
            var lastno = GetLastNumber(id);
            var ddl = document.getElementById(id);
            var flag = true;
            //          if(document.getElementById("ddlCutstomer").value=="0")
            //          {
            //            alert('Select Customer First!');
            //            document.getElementById("ddlCutstomer").focus();
            //            flag=false;
            //            ddl.value='0';
            //          }
            //          else if(document.getElementById("txtrefno").value=='')
            //          {
            //            alert('Enter Ref No.');
            //            document.getElementById("txtrefno").focus();
            //            flag=false;
            //            ddl.value='0';
            //          }
            //          else if(document.getElementById("txtdate").value=='')
            //          {
            //           alert('Enter Date');
            //           document.getElementById("txtdate").focus();
            //           flag=false;
            //           ddl.value='0';
            //          }
            if (flag == true) {
                if (document.getElementById("txtgrossamtctrl" + lastno) != null) {
                    document.getElementById("txtgrossamtctrl" + lastno).value = '0';
                }
                if (document.getElementById("txtdiscount1ctrl" + lastno) != null) {
                    document.getElementById("txtdiscount1ctrl" + lastno).value = '0';
                }
                if (document.getElementById("txtdiscount2ctrl" + lastno) != null) {
                    document.getElementById("txtdiscount2ctrl" + lastno).value = '0';
                }
                if (document.getElementById("txtservicecharge1crtl" + lastno) != null) {
                    document.getElementById("txtservicecharge1crtl" + lastno).value = '0';
                }
                if (document.getElementById("txtservicecharge2crtl" + lastno) != null) {
                    document.getElementById("txtservicecharge2crtl" + lastno).value = '0';
                }
                if (document.getElementById("txtservicecharge3crtl" + lastno) != null) {
                    document.getElementById("txtservicecharge3crtl" + lastno).value = '0';
                }
                if (document.getElementById("txtserviceTax1crtl" + lastno) != null) {
                    document.getElementById("txtserviceTax1crtl" + lastno).value = '0';
                }
                if (document.getElementById("txtserviceTax2crtl" + lastno) != null) {
                    document.getElementById("txtserviceTax2crtl" + lastno).value = '0';
                }
                if (document.getElementById("txtserviceTax3crtl" + lastno) != null) {
                    document.getElementById("txtserviceTax3crtl" + lastno).value = '0';
                }
                if (document.getElementById("txtserviceTax4crtl" + lastno) != null) {
                    document.getElementById("txtserviceTax4crtl" + lastno).value = '0';
                }
                if (document.getElementById("txtserviceTax5crtl" + lastno) != null) {
                    document.getElementById("txtserviceTax5crtl" + lastno).value = '0';
                }
                if (document.getElementById("txtTaxincGrandTotalctrl" + lastno) != null) {
                    document.getElementById("txtTaxincGrandTotalctrl" + lastno).value = '0';
                }

                //                if (document.getElementById("txttaxableamount") != null) {
                //                    document.getElementById("txttaxableamount").value = '0';
                //                }
                //                if (document.getElementById("txtdiscounttaxamt") != null) {
                //                    document.getElementById("txtdiscounttaxamt").value = '0';
                //                }
                //                if (document.getElementById("txtdiscounttaxper") != null) {
                //                    document.getElementById("txtdiscounttaxper").value = '0';
                //                }
                //                if (document.getElementById("txtnontaxableamount") != null) {
                //                    document.getElementById("txtnontaxableamount").value = '0';
                //                }
                //                if (document.getElementById("txtnondiscounttaxamt") != null) {
                //                    document.getElementById("txtnondiscounttaxamt").value = '0';
                //                }
                //                if (document.getElementById("txtnondiscounttaxper") != null) {
                //                    document.getElementById("txtnondiscounttaxper").value = '0';
                //                }
                //                if (document.getElementById("txtservicechargeamt") != null) {
                //                    document.getElementById("txtservicechargeamt").value = '0';
                //                }
                //                if (document.getElementById("txttotalamount") != null) {
                //                    document.getElementById("txttotalamount").value = '0';
                //                }
                //                if (document.getElementById("txtservicetax") != null) {
                //                    document.getElementById("txtservicetax").value = '0';
                //                }
                //                if (document.getElementById("txtpecess") != null) {
                //                    document.getElementById("txtpecess").value = '0';
                //                }
                //                if (document.getElementById("txthecess") != null) {
                //                    document.getElementById("txthecess").value = '0';
                //                }
                //                if (document.getElementById("txtluxuarytax") != null) {
                //                    document.getElementById("txtluxuarytax").value = '0';
                //                }
                //                if (document.getElementById("txtroundofamt") != null) {
                //                    document.getElementById("txtroundofamt").value = '0';
                //                }
                //                if (document.getElementById("txtgrandtotal") != null) {
                //                    document.getElementById("txtgrandtotal").value = '0';
                //                }

                setTimeout('__doPostBack(\'' + id + '\',\'\')', 0);
            }
            return flag;
        }
        function CalculateGrandTotal(id) {
            var lastno = GetLastNumber(id);
            if (document.getElementById("hidunit").value.search('u2') >= 0) {
                var unit2 = document.getElementById("txtunit2ctrl" + lastno).value;
                if (unit2 == '') {
                    unit2 = 0;
                }
                var rate = document.getElementById("txtunitrate2ctrl" + lastno).value;
                if (rate == '') {
                    rate = 0;
                    document.getElementById("txtunitrate2ctrl" + lastno).value = 0;
                }
            }
            if (document.getElementById("hidunit").value.search('u3') >= 0) {
                var unit3 = document.getElementById("txtunit3ctrl" + lastno).value;
                if (unit3 == '') {
                    unit3 = 0;
                }
                var rate = document.getElementById("txtunitrate2ctrl" + lastno).value;
                if (rate == '') {
                    rate = 0;
                    document.getElementById("txtunitrate2ctrl" + lastno).value = 0;
                }
            }
            if (document.getElementById("hidunit").value.search('u4') >= 0) {
                var unit4 = document.getElementById("txtunit4ctrl" + lastno).value;
                if (unit4 == '') {
                    unit4 = 0;
                }
                var rate = document.getElementById("txtunitrate2ctrl" + lastno).value;
                if (rate == '') {
                    rate = 0;
                    document.getElementById("txtunitrate2ctrl" + lastno).value = 0;
                }
            }

            //            var unit = document.getElementById("txtunitrate1ctrl" + lastno).value;  // Unit
            //            if (unit == '') {
            //                unit = 0;
            //            }
            //            var rate = document.getElementById("txtunitrate2ctrl" + lastno).value;
            //            if (rate == '') {
            //                rate = 0;
            //                document.getElementById("txtunitrate2ctrl" + lastno).value = 0;
            //            }

            var servicetaxper = parseFloat(document.getElementById("txtservicetaxpercent").value).toFixed(2);
            if (servicetaxper == '') {
                servicetaxper = 0;
            }
            var pecesstaxper = parseFloat(document.getElementById("txtpecesspercent").value).toFixed(2);
            if (pecesstaxper == '') {
                pecesstaxper = 0;
            }
            var hecesstaxper = parseFloat(document.getElementById("txthecesspercent").value).toFixed(2);
            if (hecesstaxper == '') {
                hecesstaxper = 0;
            }
            var luxuarytaxper = parseFloat(document.getElementById("txtluxuarytaxpercent").value).toFixed(2);
            if (luxuarytaxper == '') {
                luxuarytaxper = 0;
            }
            document.getElementById("txtserviceTax1crtl" + lastno).value = '0';
            document.getElementById("txtserviceTax2crtl" + lastno).value = '0';
            document.getElementById("txtserviceTax3crtl" + lastno).value = '0';
            if (document.getElementById("ddlservice" + lastno).value != "0") {

                var ServiceChargeper = Number(document.getElementById("txtservicecharge1crtl" + lastno).value);
                if (ServiceChargeper == '') {
                    ServiceChargeper = 0;
                }
                var servicechargeRate = parseFloat((parseFloat(parseFloat(ServiceChargeper) * 100) / 1000 / 10) + 1).toFixed(2);
                var ServiceTaxRate = (parseFloat(parseFloat(servicetaxper) + (parseFloat(pecesstaxper) / 10) + (parseFloat(hecesstaxper) / 10) + (parseFloat(luxuarytaxper) / 10)) * 100 / 1000 / 10) + 1;
                if (document.getElementById("hidGrandTotal").value == 'yes') { // Grand Total 
                    // with Grand Total
                }
                else { // No Grand Total  *********************
                    if (document.getElementById("hidunitrate").value == "yes") {  // Rate Active

                    }
                    else { // Gross Amount Active ******************
                        if (document.getElementById("hidunit").value != '') { // Additional Unit

                            var Ratetemp = 0;
                            var TotalUnit = 0;
                            var rate = 0;
                            rate = Number(document.getElementById("txtunitrate2ctrl" + lastno).value);
                            if (TotalUnit > 0) {
                                Ratetemp = parseFloat(TotalUnit) * parseFloat(rate);
                            }
                            else {
                                Ratetemp = rate;
                            }
                            if (document.getElementById("hidunit").value.search('u2') >= 0) {
                                TotalUnit = parseFloat(unit2);
                                if (TotalUnit > 0) {
                                    Ratetemp = (parseFloat(Ratetemp) * parseFloat(TotalUnit));
                                }
                            }
                            if (document.getElementById("hidunit").value.search('u3') >= 0) {
                                TotalUnit = parseFloat(unit3);
                                if (TotalUnit > 0) {
                                    Ratetemp = (parseFloat(Ratetemp) * parseFloat(TotalUnit));
                                }
                            }
                            if (document.getElementById("hidunit").value.search('u4') >= 0) {
                                TotalUnit = parseFloat(unit4);
                                if (TotalUnit > 0) {
                                    Ratetemp = (parseFloat(Ratetemp) * parseFloat(TotalUnit));
                                }
                            }
                            GrossAmt = parseFloat(Ratetemp);
                            document.getElementById("txtgrossamtctrl" + lastno).value = parseFloat(GrossAmt);
                        }
                        else {
                            GrossAmt = document.getElementById("txtgrossamtctrl" + lastno).value;
                        }
                        if (GrossAmt != null) { 
                            var GrossAmount = 0;
                            var servicechargeAmtount = 0;
                            var TotalAmount = 0;
                            if (document.getElementById("hidTaxableNonTaxable" + lastno).value == 'Taxable') {
                                //GrossAmount = (parseFloat(Grandtotal) / GrossRate);
                                servicechargeAmtount = (parseFloat(GrossAmt) * parseFloat(ServiceChargeper) / 100).toFixed(2);
                                TotalAmount = (parseFloat(GrossAmt) + parseFloat(servicechargeAmtount));
                            }
                            else {
                                //GrossAmount = (parseFloat(GrossAmt) / servicechargerate);
                                servicechargeAmtount = (parseFloat(GrossAmt) * parseFloat(ServiceChargeper) / 100).toFixed(2);
                                TotalAmount = (parseFloat(GrossAmt) + parseFloat(servicechargeAmtount));
                            }
                            document.getElementById("txtservicecharge2crtl" + lastno).value = parseFloat(servicechargeAmtount).toFixed(2);      // Service Charge Amount
                            document.getElementById("txtservicecharge3crtl" + lastno).value = parseFloat(TotalAmount).toFixed(2);   // Total Amount Header
                            // Discount 
                            if (document.getElementById("txtdiscount1ctrl" + lastno).value == '') {
                                document.getElementById("txtdiscount1ctrl" + lastno).value = 0;
                            }
                            document.getElementById("txtdiscount2ctrl" + lastno).value = (parseFloat(document.getElementById("txtgrossamtctrl" + lastno).value) * (parseFloat(document.getElementById("txtdiscount1ctrl" + lastno).value)) / 100).toFixed(2);

                            var disserper = ((parseFloat(servicechargeAmtount)) * (parseFloat(document.getElementById("txtdiscount2ctrl" + lastno).value)) / 100).toFixed(2);      // Service Charge Amount
                            document.getElementById("txtservicecharge2crtl" + lastno).value = (parseFloat(servicechargeAmtount) - parseFloat(disserper));
                            var distotper = ((parseFloat(TotalAmount)) * (parseFloat(document.getElementById("txtdiscount2ctrl" + lastno).value)) / 100);
                            document.getElementById("txtservicecharge3crtl" + lastno).value = ((parseFloat(TotalAmount)) - (parseFloat(distotper))).toFixed(2);   // Total Amount Header
                            // Discount End
                            // Service Tax
                            var totalamounthead = parseFloat(document.getElementById("txtservicecharge3crtl" + lastno).value);
                            if (totalamounthead == '') {
                                totalamounthead = 0;
                            }
                            if (document.getElementById("hidTaxableNonTaxable" + lastno).value == 'Taxable') {
                                document.getElementById("txtserviceTax1crtl" + lastno).value = (parseFloat(parseFloat(totalamounthead)) * parseFloat(servicetaxper) / 100).toFixed(2);    // Service Tax
                                document.getElementById("txtserviceTax2crtl" + lastno).value = (parseFloat(parseFloat(totalamounthead)) * parseFloat(pecesstaxper / 10) / 100).toFixed(2);   // P.E Cess
                                document.getElementById("txtserviceTax3crtl" + lastno).value = (parseFloat(parseFloat(totalamounthead)) * parseFloat(hecesstaxper / 10) / 100).toFixed(2);  // H.E Cess
                                document.getElementById("txtserviceTax4crtl" + lastno).value = '0'; // Luxuary Tax
                                document.getElementById("txtserviceTax5crtl" + lastno).value = '0'; // VAT Tax

                                document.getElementById("txtTaxincGrandTotalctrl" + lastno).value = parseFloat(parseFloat(totalamounthead) + (parseFloat(document.getElementById("txtserviceTax1crtl" + lastno).value)) + (parseFloat(document.getElementById("txtserviceTax2crtl" + lastno).value)) + (parseFloat(document.getElementById("txtserviceTax3crtl" + lastno).value)) + (parseFloat(document.getElementById("txtserviceTax4crtl" + lastno).value)) + (parseFloat(document.getElementById("txtserviceTax5crtl" + lastno).value))).toFixed(2);
                            }
                            else {
                                document.getElementById("txtserviceTax1crtl" + lastno).value = '0';
                                document.getElementById("txtserviceTax2crtl" + lastno).value = '0';
                                document.getElementById("txtserviceTax3crtl" + lastno).value = '0';

                                document.getElementById("txtTaxincGrandTotalctrl" + lastno).value = parseFloat(totalamounthead).toFixed(2);
                            }
                            // Service Tax End
                                   ////////// Bottom //////////
                            var totTaxableAmount = 0;
                            var totNonTaxableAmount = 0;
                            var totServiceChargeAmount = 0;
                            var totservAmt = 0;
                            var totpecessAmt = 0;
                            var tothecessAmt = 0;
                            var totluxuaryAmt = 0;
                            var totVatAmt = 0;
                            var TotalAmount = 0;
                            for (var i = 1; i <= parseFloat(document.getElementById("hcount").value); i++) {
                                             //////////// Txable Amount,NonTaxableAmount,TotalAmount //////////
                                var temptotTaxableAmount = Number(document.getElementById("txtgrossamtctrl" + i).value);
                                var temptotNonTaxableAmount = Number(document.getElementById("txtgrossamtctrl" + i).value);
                                var temptotServiceChargeAmount = Number(document.getElementById("txtservicecharge2crtl" + i).value);
                                var tempTotalAmount = Number(document.getElementById("txtservicecharge3crtl" + i).value);
                                if (temptotTaxableAmount == '' || temptotNonTaxableAmount == '') {
                                    temptotTaxableAmount = 0;
                                    temptotNonTaxableAmount = 0;
                                }
                                if (document.getElementById("hidTaxableNonTaxable" + i).value == 'Taxable') {
                                    totTaxableAmount += parseFloat(temptotTaxableAmount);
                                }
                                else {
                                    totNonTaxableAmount += parseFloat(temptotNonTaxableAmount);
                                }
                                if (temptotServiceChargeAmount == '') {
                                    temptotServiceChargeAmount = 0;
                                }
                                totServiceChargeAmount += parseFloat(temptotServiceChargeAmount);
                                if (tempTotalAmount == '') {
                                    tempTotalAmount = 0;
                                }
                                TotalAmount += parseFloat(tempTotalAmount);
                            }
                            document.getElementById("txttaxableamount").value = parseFloat(totTaxableAmount).toFixed(2);
                            document.getElementById("txtnontaxableamount").value = parseFloat(totNonTaxableAmount).toFixed(2);
                            document.getElementById("txtservicechargeamt").value = parseFloat(totServiceChargeAmount).toFixed(2);
                            document.getElementById("txttotalamount").value = parseFloat(TotalAmount).toFixed(2);


                            //RoundAmountBottom(id);
                                  
                                 ///////// Bottom End ///////////
                        }
                    }
                }
            }
            else {
                alert('Select Service First!!!');
                document.getElementById("ddlservice" + lastno).focus();
            }
        }
        function discountbill(taxablenontaxable,id) {
         var lastno = GetLastNumber(id);
            var disper=Number(document.getElementById("txtdiscounttaxper").value);
            var disnonper=Number(document.getElementById("txtnondiscounttaxper").value);
            if (document.getElementById("hidDiscount").value == 'BillLevel') {
            
             
                var originaltaxableamt = 0;
                var originalnontaxableamt = 0;
                for (var i = 1; i <= parseFloat(document.getElementById("hcount").value); i++) {
                    if (document.getElementById("hidTaxableNonTaxable" + i).value == 'Taxable') {
                        
                        document.getElementById("txtdiscount1ctrl" + i).value = parseFloat(disper);
                        document.getElementById("txtdiscount1ctrl" + i).Blur = "return CalculateGrandTotal('txtdiscount1ctrl' + " + i + ");";
                        //document.getElementById("txtdiscount1ctrl" + i).focus();
                        document.getElementById("txtservicecharge1crtl" + i).focus();
                        document.getElementById("txtgrossamtctrl" + i).focus();
                      
                    }
                    else {
                        
                        document.getElementById("txtdiscount1ctrl" + i).value = parseFloat(disnonper);
                        document.getElementById("txtdiscount1ctrl" + i).Blur = "return CalculateGrandTotal('txtdiscount1ctrl' + " + i + ");";
                        //document.getElementById("txtdiscount1ctrl" + i).focus();
                        document.getElementById("txtservicecharge1crtl" + i).focus();
                        document.getElementById("txtgrossamtctrl" + i).focus();
                        
                    }
                    //                    var temp = document.getElementById("txtgrossamtctrl" + i).value;
                    //                    if (temp == '') {
                    //                        temp = 0;
                    //                    }
                    //                    var tempnon = document.getElementById("txtgrossamtctrl" + i).value;
                    //                    if (tempnon == '') {
                    //                        tempnon = 0;
                    //                    }
                    //                    if (document.getElementById("hidTaxableNonTaxable" + i).value == 'Taxable') {
                    //                        originaltaxableamt += parseFloat(temp);
                    //                    }
                    //                    else {
                    //                        originalnontaxableamt += parseFloat(tempnon);
                    //                    }
                }
                if (taxablenontaxable == "taxable") {
                    if (parseFloat(originaltaxableamt) != '') {
//                        document.getElementById("txtdiscounttaxamt").value = (parseFloat(originaltaxableamt) * parseFloat(document.getElementById("txtdiscounttaxper").value) / 100).toFixed(2);
//                        document.getElementById("txttaxableamount").value = (parseFloat(originaltaxableamt) - parseFloat(document.getElementById("txtdiscounttaxamt").value)).toFixed(2);
                    }
                }
                else {
                    if (parseFloat(originalnontaxableamt) != '') {
                        document.getElementById("txtnondiscounttaxamt").value = (parseFloat(originalnontaxableamt) * parseFloat(document.getElementById("txtnondiscounttaxper").value) / 100).toFixed(2);
                        document.getElementById("txtnontaxableamount").value = (parseFloat(originalnontaxableamt) - parseFloat(document.getElementById("txtnondiscounttaxamt").value)).toFixed(2);
                    }
                }
            }
        }
        function RoundAmountBottom(id) {
            var lastno = GetLastNumber(id);

            var TotalAmount = 0;
            var tempTotalAmount = 0;
            var TotalEntryAmount = 0;
            var tempTotalEntryAmount = 0;
            var TotalTxableamount = 0;
            var TotalTxableamountHeader = 0;
            for (var i = 1; i <= parseFloat(document.getElementById("hcount").value); i++) {
                tempTotalAmount = document.getElementById("txtservicecharge3crtl" + i).value;
                if (tempTotalAmount == '') {
                    tempTotalAmount = 0;
                }
                TotalAmount += parseFloat(tempTotalAmount);
                if (document.getElementById("hidGrandTotal").value == 'yes') {
                    tempTotalEntryAmount = document.getElementById("txtTaxincGrandTotalctrl" + i).value;
                }
                else {
                    tempTotalEntryAmount = document.getElementById("txtservicecharge3crtl" + i).value;
                }
                if (tempTotalEntryAmount == '') {
                    tempTotalEntryAmount = 0;
                }
                TotalEntryAmount += parseFloat(tempTotalEntryAmount);

                if (document.getElementById("hidTaxableNonTaxable" + i).value == 'Taxable') {
                    var servicetaxper = parseFloat(document.getElementById("txtservicetaxpercent").value).toFixed(2);
                    if (servicetaxper == '') {
                        servicetaxper = 0;
                    }
                    var pecesstaxper = parseFloat(document.getElementById("txtpecesspercent").value).toFixed(2);
                    if (pecesstaxper == '') {
                        pecesstaxper = 0;
                    }
                    var hecesstaxper = parseFloat(document.getElementById("txthecesspercent").value).toFixed(2);
                    if (hecesstaxper == '') {
                        hecesstaxper = 0;
                    }
                    var luxuarytaxper = parseFloat(document.getElementById("txtluxuarytaxpercent").value).toFixed(2);
                    if (luxuarytaxper == '') {
                        luxuarytaxper = 0;
                    }
                    var temptotaltaxableamount = document.getElementById("txtservicecharge3crtl" + i).value;
                    if (temptotaltaxableamount == '') {
                        temptotaltaxableamount = 0;
                    }
                    TotalTxableamount += parseFloat(temptotaltaxableamount);
                    document.getElementById("txtservicetax").value = (parseFloat(parseFloat(TotalTxableamount)) * parseFloat(servicetaxper) / 100).toFixed(2);
                    document.getElementById("txtpecess").value = (parseFloat(parseFloat(TotalTxableamount)) * parseFloat(pecesstaxper / 10) / 100).toFixed(2);
                    document.getElementById("txthecess").value = (parseFloat(parseFloat(TotalTxableamount)) * parseFloat(hecesstaxper / 10) / 100).toFixed(2);
                    document.getElementById("txtluxuarytax").value = '0';
                }

            }


            if (document.getElementById("hidSaleLevel").value == "ItemLevel") {
                var temptotaltaxableamountheader = document.getElementById("txtservicecharge3crtl" + lastno).value;
                if (temptotaltaxableamountheader == '') {
                    temptotaltaxableamountheader = 0;
                }
                TotalTxableamountHeader = parseFloat(temptotaltaxableamountheader);
                document.getElementById("txtserviceTax1crtl" + lastno).value = (parseFloat(parseFloat(TotalTxableamountHeader)) * parseFloat(servicetaxper) / 100).toFixed(2);    // Service Tax
                document.getElementById("txtserviceTax2crtl" + lastno).value = (parseFloat(parseFloat(TotalTxableamountHeader)) * parseFloat(pecesstaxper / 10) / 100).toFixed(2);   // P.E Cess
                document.getElementById("txtserviceTax3crtl" + lastno).value = (parseFloat(parseFloat(TotalTxableamountHeader)) * parseFloat(hecesstaxper / 10) / 100).toFixed(2);  // H.E Cess
            }

            var servicetaxamount = document.getElementById("txtservicetax").value;
            if (servicetaxamount == '') {
                servicetaxamount = 0;
            }
            var TaxPeCessamount = document.getElementById("txtpecess").value;
            if (TaxPeCessamount == '') {
                TaxPeCessamount = 0;
            }
            var TaxHeCessamount = document.getElementById("txthecess").value;
            if (TaxHeCessamount == '') {
                TaxHeCessamount = 0;
            }
            var TaxLuxuaryTax = document.getElementById("txtluxuarytax").value;
            if (TaxLuxuaryTax == '') {
                TaxLuxuaryTax = 0;
            }

            var roundoffamt = 0;
            var temproundoffamt = 0;

            temproundoffamt = (parseFloat(TotalAmount) + parseFloat(servicetaxamount) + parseFloat(TaxPeCessamount) + parseFloat(TaxHeCessamount) + parseFloat(TaxLuxuaryTax)).toFixed(2);
            roundoffamt = (parseFloat(TotalEntryAmount) - parseFloat(temproundoffamt)).toFixed(2);
            if (parseFloat(TotalAmount) > parseFloat(TotalEntryAmount)) {
                roundoffamt = 0 - (parseFloat(TotalAmount) - parseFloat(TotalEntryAmount)).toFixed(2);
            }
            //alert(TotalAmount);
            document.getElementById("txtroundofamt").value = roundoffamt;
            document.getElementById("txtgrandtotal").value = TotalEntryAmount.toFixed(2);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="divmain" style="width: 96%; margin-left: 1%;">
        <acc:heading ID="pagehead" runat="server" HeadingText="Sale Invoice" />
        <div style="margin-left: 5%; margin-right: 3%; width: 85%" align="center">
            <asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label>
        </div>
    </div>
    
    <div style="width: 96%; margin-left: 1%; margin-top: 10px;">
        <table style="width: 100%;" class="tablecontent">
            <tr>
                <td>
                    <b>Bill Format <span style="color: Red">* </span></b>
                </td>
                <td>
                    <asp:DropDownList ID="ddlFormat" runat="server" CssClass="dropdown" AutoPostBack="true" OnSelectedIndexChanged="ddlFormat_SelectedIndex">
                    </asp:DropDownList>
                    <asp:HiddenField ID="hidSaleLevel" runat="server" /> <%-- Item Level Or Bill Level --%> 
                    <asp:HiddenField ID="hidGrandTotal" runat="server" /> <%-- TaxInclusive --%>
                    <asp:HiddenField ID="hidsercharge" runat="server" /> <%-- Show Service Charge --%>
                    <asp:HiddenField ID="hidTaxType" runat="server" />   <%-- ServiceTax ServiceTax,LuxuaryTax ServiceTax,VAT --%> 
                    <asp:HiddenField ID="hidDiscount" runat="server" />  <%-- Apply Discount None,BillLevel,ItemLevel --%> 
                    <asp:HiddenField ID="hidunit" runat="server" />  <%-- Addition Unit Height,Widht,Radious --%> 
                    <asp:HiddenField ID="hidunitrate" runat="server" /> <%-- Unit and Rate --%>
                    
                </td>
                <td>
                    <b>Customer <span style="color: Red;">* </span></b>
                </td>
                <td>
                    <asp:DropDownList ID="ddlCutstomer" runat="server" CssClass="dropdown" AutoPostBack="true" OnSelectedIndexChanged="ddlCutstomer_SelectedIndex" Width="200px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Bill No. <span style="color:Red;"> * </span></b>
                </td>
                <td>
                    <asp:TextBox ID="txtPrefix" runat="server" Width="60px" CssClass="input" onKeyPress="return false"
                        onKeydown="return false"></asp:TextBox>
                    <AjaxControl:textboxwatermarkextender id="prefixWater" runat="server" targetcontrolid="txtPrefix"
                        watermarktext="Prefix" watermarkcssclass="watermark_textbox"></AjaxControl:textboxwatermarkextender>
                    <asp:TextBox ID="txtbillno" runat="server" Width="60px" CssClass="inputnumber" ValidationGroup="V"
                        MaxLength="10"></asp:TextBox>
                    <AjaxControl:textboxwatermarkextender id="voucherWater" runat="server" targetcontrolid="txtbillno"
                        watermarktext="Number" watermarkcssclass="watermark_textbox"></AjaxControl:textboxwatermarkextender>
                    <asp:TextBox ID="txtSuffix" runat="server" Width="60px" CssClass="input" onKeyPress="return false"
                        onKeydown="return false"></asp:TextBox>
                    <AjaxControl:textboxwatermarkextender id="suffixWater" runat="server" targetcontrolid="txtSuffix"
                        watermarktext="Suffix" watermarkcssclass="watermark_textbox"></AjaxControl:textboxwatermarkextender>
                </td>
                <td>
                    <b>Address</b>
                </td>
                <td colspan="5">
                    <asp:TextBox ID="txtaddress" runat="server" CssClass="input" Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Date <span style="color: Red;">* </span></b>
                </td>
                <td>
                    <asp:TextBox ID="txtdate" runat="server" CssClass="input" OnTextChanged="BTNDATE_CLICK" AutoPostBack="true"></asp:TextBox>
                    <asp:ImageButton ID="btnDate" runat="server" ImageUrl="~/Images/calendar.gif"  />
                    <AjaxControl:calendarextender id="calrec" runat="server" popupbuttonid="btnDate"
                        targetcontrolid="txtdate" format="dd/MM/yyyy"></AjaxControl:calendarextender>
                    <AjaxControl:maskededitextender id="maskExtrec" runat="server" masktype="Date" mask="99/99/9999"
                        targetcontrolid="txtdate" culturename="en-GB"></AjaxControl:maskededitextender>
                    <AjaxControl:maskededitvalidator id="maskValidrec" runat="server" controlextender="maskExtrec"
                        invalidvaluemessage="Invalid Date" isvalidempty="true" display="Dynamic" validationgroup="V"
                        controltovalidate="txtdate"></AjaxControl:maskededitvalidator>
                </td>
                <td>
                    <b>Ref no <span style="color: Red">*</span></b>
                </td>
                <td>
                    <asp:TextBox ID="txtrefno" runat="server" CssClass="inputnumber" Style="width: 70px;"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Other Ref</b>
                </td>
                <td>
                    <asp:TextBox ID="txtotherref" runat="server" CssClass="input" Style="width: 70px;"></asp:TextBox>
                </td>
                <td>
                    <b>Cr Days</b>
                </td>
                <td>
                    <asp:TextBox ID="txtcrdays" runat="server" CssClass="inputnumber" Style="width: 70px;"></asp:TextBox>
                    <asp:HiddenField ID="hidCustomerprefid" runat="server" />
                </td>
            </tr>
        </table>
        <div style="overflow:scroll; width:100%; margin-top:10px;" class="tablecontent"> 
        <asp:HiddenField ID="hcount" runat="server" Value="2" />
            <table id="tblmain" runat="server" width="100%" style="margin-bottom:10px;">
              <tr>
                <td style="border-right:1px solid #818181;" class="headtd" align="center" id="tdservice" runat="server"><b>Nature of Service</b></td>
                <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tddescription" runat="server"><b>Description</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdyearref" runat="server"><b>Year Ref.</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tduom" runat="server"><b>Unit of Mesurement</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdunit2" runat="server"><b>Unit 2</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdunit3" runat="server"><b>Unit 3</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdunit4" runat="server"><b>Unit 4</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdunitrate1" runat="server"><b>Unit</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdunitrate2" runat="server"><b>Rate</b></td>
               <td style="border-right:1px solid #818181;" class="headtd" align="center" id="tdgrossamt" runat="server"><b>Gross Amount</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tddiscount1" runat="server"><b>Discount %</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tddiscount2" runat="server"><b>Discount Amount</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdservicecharge1" runat="server"><b>Service Charge %</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdservicecharge2" runat="server"><b>Service Charge</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdservicecharge3" runat="server"><b>Total Amount</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdserviceTax1" runat="server"><b>Service Tax</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdserviceTax2" runat="server"><b>P.E Cess</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdserviceTax3" runat="server"><b>H.E Cess</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdserviceTax4" runat="server"><b>Luxury</b></td>
               <td  style="display:none; border-right:1px solid #818181;" class="headtd" align="center" id="tdserviceTax5" runat="server"><b>VAT</b></td>
               <td  style="display:none;" class="headtd" align="center" id="tdTaxincGrandTotal" runat="server"><b>Grand Total</b></td>
              </tr>
              <tr>
                <td id="tdservicectrl1" runat="server"   align="center"><asp:DropDownList ID="ddlservice1" runat="server" AutoPostBack="true" CssClass="dropdown" Width="150px" OnSelectedIndexChanged="ddlservice_SelectedIndexChanged" onchange="return ValidateRequired(this.id);"></asp:DropDownList>
                  <asp:HiddenField ID="hidTaxableNonTaxable1" runat="server" />
                </td>
                <td style=" display:none;" id="tddescriptionctrl1" runat="server"   align="center"><asp:TextBox ID="txtdescriptionctrl1" runat="server" CssClass="input" style="display:none;"></asp:TextBox></td>
                <td style=" display:none;" id="tdyearrefctrl1" runat="server"   align="center"><asp:TextBox ID="txtyearrefctrl1" runat="server" CssClass="input" style="width:70px; display:none;"></asp:TextBox></td>
                <td style=" display:none;" id="tduomctrl1" runat="server"   align="center"><asp:TextBox ID="txtuomctrl1" runat="server" CssClass="input" style="display:none;"></asp:TextBox></td>
                <td style=" display:none;" id="tdunit2ctrl1" runat="server"   align="center"><asp:TextBox ID="txtunit2ctrl1" runat="server" CssClass="inputnumber" style="width:70px;display:none;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdunit3ctrl1" runat="server"   align="center"><asp:TextBox ID="txtunit3ctrl1" runat="server" CssClass="inputnumber" style="width:70px;display:none;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdunit4ctrl1" runat="server"   align="center"><asp:TextBox ID="txtunit4ctrl1" runat="server" CssClass="inputnumber" style="width:70px;display:none;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdunitrate1ctrl1" runat="server"   align="center"><asp:TextBox ID="txtunitrate1ctrl1" runat="server" CssClass="inputnumber" style="width:70px; display:none;" OnKeyPress="return isNumberKey(this.ID,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
                <td style=" display:none;" id="tdunitrate2ctrl1" runat="server"   align="center"><asp:TextBox ID="txtunitrate2ctrl1" runat="server" CssClass="DisableInputNumber" style="width:70px;display:none;"  onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
                <td  id="tdgrossamtctrl1" runat="server"   align="center"><asp:TextBox ID="txtgrossamtctrl1" runat="server" CssClass="DisableInputNumber" style="width:120px;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox><asp:HiddenField ID="hidServiceCharge1" runat="server" /></td>
                <td style=" display:none;" id="tddiscount1ctrl1" runat="server"   align="center"><asp:TextBox ID="txtdiscount1ctrl1" runat="server" style="width:80px; display:none;" CssClass="inputnumber" OnKeyPress="return isNumberKey(this.ID,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
                <td style=" display:none;" id="tddiscount2ctrl1" runat="server"   align="center"><asp:TextBox ID="txtdiscount2ctrl1" runat="server" style="width:120px; display:none;" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdservicecharge1crtl1" runat="server"   align="center"><asp:TextBox ID="txtservicecharge1crtl1" style="width:120px; display:none;" runat="server" CssClass="inputnumber" OnKeyPress="return isNumberKey(this.ID,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
                <td style=" display:none;" id="tdservicecharge2crtl1" runat="server"   align="center"><asp:TextBox ID="txtservicecharge2crtl1" style="width:100px; display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdservicecharge3crtl1" runat="server"   align="center"><asp:TextBox ID="txtservicecharge3crtl1" style="width:100px; display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax1crtl1" runat="server"   align="center"><asp:TextBox ID="txtserviceTax1crtl1" style="width:100px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax2crtl1" runat="server"   align="center"><asp:TextBox ID="txtserviceTax2crtl1" style="width:70px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax3crtl1" runat="server"   align="center"><asp:TextBox ID="txtserviceTax3crtl1" style="width:70px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax4crtl1" runat="server"   align="center"><asp:TextBox ID="txtserviceTax4crtl1" style="width:70px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax5crtl1" runat="server"   align="center"><asp:TextBox ID="txtserviceTax5crtl1" style="width:70px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdTaxincGrandTotalctrl1" runat="server"   align="center"><asp:TextBox ID="txtTaxincGrandTotalctrl1" runat="server" style="width:120px;display:none;" CssClass="inputnumber" OnKeyPress="return isNumberKey(this.ID,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
              </tr>
               <tr>
                <td id="tdservicectrl2" runat="server"   align="center"><asp:DropDownList ID="ddlservice2" runat="server" AutoPostBack="true" CssClass="dropdown" Width="150px" OnSelectedIndexChanged="ddlservice_SelectedIndexChanged" onchange="return ValidateRequired(this.id);"></asp:DropDownList>
                 <asp:HiddenField ID="hidTaxableNonTaxable2" runat="server" />
                </td>
                <td style=" display:none;" id="tddescriptionctrl2" runat="server"   align="center"><asp:TextBox ID="txtdescriptionctrl2" runat="server" CssClass="input" style="display:none;"></asp:TextBox></td>
                <td style=" display:none;" id="tdyearrefctrl2" runat="server"   align="center"><asp:TextBox ID="txtyearrefctrl2" runat="server" CssClass="input" style="width:70px;display:none;"></asp:TextBox></td>
                <td style=" display:none;" id="tduomctrl2" runat="server"   align="center"><asp:TextBox ID="txtuomctrl2" runat="server" CssClass="input" style="display:none;"></asp:TextBox></td>
                <td style=" display:none;" id="tdunit2ctrl2" runat="server"   align="center"><asp:TextBox ID="txtunit2ctrl2" runat="server" CssClass="inputnumber" style="width:70px;display:none;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdunit3ctrl2" runat="server"   align="center"><asp:TextBox ID="txtunit3ctrl2" runat="server" CssClass="inputnumber" style="width:70px;display:none;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdunit4ctrl2" runat="server"   align="center"><asp:TextBox ID="txtunit4ctrl2" runat="server" CssClass="inputnumber" style="width:70px;display:none;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdunitrate1ctrl2" runat="server"   align="center"><asp:TextBox ID="txtunitrate1ctrl2" runat="server" CssClass="inputnumber" style="width:70px;display:none;" OnKeyPress="return isNumberKey(this.ID,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
                <td style=" display:none;" id="tdunitrate2ctrl2" runat="server"   align="center"><asp:TextBox ID="txtunitrate2ctrl2" runat="server" CssClass="DisableInputNumber" style="width:70px;display:none;"  onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
                <td  id="tdgrossamtctrl2" runat="server"   align="center"><asp:TextBox ID="txtgrossamtctrl2" runat="server" CssClass="DisableInputNumber" style="width:120px;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox><asp:HiddenField ID="hidServiceCharge2" runat="server" /></td>
                <td style=" display:none;" id="tddiscount1ctrl2" runat="server"   align="center"><asp:TextBox ID="txtdiscount1ctrl2" runat="server" style="width:80px;display:none;" CssClass="inputnumber" OnKeyPress="return isNumberKey(this.ID,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
                <td style=" display:none;" id="tddiscount2ctrl2" runat="server"   align="center"><asp:TextBox ID="txtdiscount2ctrl2" runat="server" style="width:120px;display:none;" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdservicecharge1crtl2" runat="server"   align="center"><asp:TextBox ID="txtservicecharge1crtl2" style="width:120px;display:none;" runat="server" CssClass="inputnumber" OnKeyPress="return isNumberKey(this.ID,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
                <td style=" display:none;" id="tdservicecharge2crtl2" runat="server"   align="center"><asp:TextBox ID="txtservicecharge2crtl2" style="width:100px;display:none;" runat="server" CssClass="DisableInputNumber"  onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdservicecharge3crtl2" runat="server"   align="center"><asp:TextBox ID="txtservicecharge3crtl2" style="width:100px;display:none;" runat="server" CssClass="DisableInputNumber"  onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax1crtl2" runat="server"   align="center"><asp:TextBox ID="txtserviceTax1crtl2" style="width:100px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax2crtl2" runat="server"   align="center"><asp:TextBox ID="txtserviceTax2crtl2" style="width:70px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax3crtl2" runat="server"   align="center"><asp:TextBox ID="txtserviceTax3crtl2" style="width:70px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax4crtl2" runat="server"  align="center"><asp:TextBox ID="txtserviceTax4crtl2" style="width:70px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdserviceTax5crtl2" runat="server"  align="center"><asp:TextBox ID="txtserviceTax5crtl2" style="width:70px;display:none;" runat="server" CssClass="DisableInputNumber" onKeyDown="return EnabledTabKey(this.id, event);"></asp:TextBox></td>
                <td style=" display:none;" id="tdTaxincGrandTotalctrl2" runat="server"  align="center"><asp:TextBox ID="txtTaxincGrandTotalctrl2" runat="server" style="width:120px;display:none;" CssClass="inputnumber" OnKeyPress="return isNumberKey(this.ID,event);" onBlur="return CalculateGrandTotal(this.id);"></asp:TextBox></td>
              </tr>
            </table>
             <table style="width:90%; margin-top:10px; margin-bottom:10px; margin-left:15px;" align="left">
                            <tr>
                                <td > 
                                    <asp:LinkButton ID="btnAddMore" runat="server" onclick="AddMore_Click"> 
                                        <img src="../../Images/More.jpg" alt="Add New Row" />
                                    </asp:LinkButton> 
                                </td>
                            </tr>
                    </table>
        </div>
    </div>
    <table style="width: 96%; margin-left: 1%; margin-top: 10px;" class="tablecontent">
       <tr>
         <td style="width:60%;" valign="top">
            <table style="width: 100%; margin-top:4px;"  class="tablecontent">
            <tr>
              <td>
             <table style="width: 100%;" cellpadding="0" cellspacing="0">
                 <tr>
                     <td class="headtd" style="width: 100%;" colspan="3">
                         <b>Post Billing</b>
                     </td>
                 </tr>
                 <tr>
                     <td class="headtd" style="width: 100%;" colspan="3">
                         <b>Current Bill</b>
                     </td>
                 </tr>
                 <tr>
                     <td colspan="3">
                         <asp:CheckBox ID="chkapplysurcurr" runat="server" Text="ApplySurcharge" Checked="true" />
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <b>Effective Rate</b>
                     </td>
                     <td>
                         <b>Net TDS</b>
                     </td>
                     <td>
                         <b>Net Amt Receivable </b>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <asp:TextBox ID="txteffectiveratecurr" runat="server" CssClass="DisableInputNumber"
                             Enabled="false" style="width:120px;"></asp:TextBox>
                     </td>
                     <td>
                         <asp:TextBox ID="txtnettdscurr" runat="server" CssClass="DisableInputNumber" Enabled="false" style="width:120px;"></asp:TextBox>
                     </td>
                     <td>
                         <asp:TextBox ID="txtnetamtreceiablecurr" runat="server" CssClass="DisableInputNumber"
                             Enabled="false" style="width:120px;"></asp:TextBox>
                     </td>
                 </tr>
                 <tr>
                     <td class="headtd" style="width: 100%;" colspan="3">
                         <b>Previous Bill</b>
                     </td>
                 </tr>
                 <tr>
                     <td colspan="3">
                         <asp:CheckBox ID="chkappsurpre" runat="server" Text="ApplySurcharge" Checked="true" />
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <b>Effective Rate</b>
                     </td>
                     <td>
                         <b>Net TDS</b>
                     </td>
                     <td colspan="2">
                         <b>Net Amt Receivable </b>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <asp:TextBox ID="txteffectiveratepre" runat="server" CssClass="DisableInputNumber"
                             Enabled="false" style="width:120px;"></asp:TextBox>
                     </td>
                     <td>
                         <asp:TextBox ID="txtnettdspre" runat="server" CssClass="DisableInputNumber" Enabled="false" style="width:120px;"></asp:TextBox>
                     </td>
                     <td colspan="2">
                         <asp:TextBox ID="txtnetamtreceiablepre" runat="server" CssClass="DisableInputNumber"
                             Enabled="false" style="width:120px;"></asp:TextBox>
                     </td>
                 </tr>
             </table>
  
         <table style="width:100%; margin-top:10px;">
         <tr >
             <td id="tdnarration" runat="server"><b>Narration</b></td><td id="tdnarrationtext" runat="server"><asp:TextBox ID="txtnarration" runat="server" CssClass="input" style="width:130px;"></asp:TextBox></td>
             <td id="tdservicedby" runat="server" ><b>Serviced By</b></td><td id="tdservicedbytext" runat="server"><asp:TextBox ID="txtservicedby" runat="server" CssClass="input"  style="width:130px;"></asp:TextBox></td>
         </tr>
         <tr>
          <td id="tdpreparedby" runat="server" ><b>Prepared By</b></td><td id="tdpreparedbytext" ><asp:TextBox ID="txtpreparedby" runat="server" CssClass="input" style="width:130px;"></asp:TextBox></td>
          <td id="tdcheckedby" runat="server"><b>Checked By</b></td><td id="tdcheckedbytext"><asp:TextBox ID="txtcheckedby" runat="server" CssClass="input" style="width:130px;"></asp:TextBox></td>
         </tr>
         <tr>
           <td id="tdremarks" runat="server"><b>Remarks</b></td><td id="tdremarkstext" colspan="3" style="width:80%;"><asp:TextBox ID="txtremarks" runat="server" style="width:80%;"  CssClass="input"></asp:TextBox></td>
         </tr>
       </table>
        </td>
      </tr>
      </table> 
    </td>
         <td style="width:40%;" valign="top">
            <table id="tblcalculation" runat="server" style="width:99%;  margin-top:4px;" class="tablecontent">
                <tr>
                    <td class="headtd" colspan="3">
                        &nbsp;
                    </td>
                </tr>
              <tr>
                <td id="tdtaxableamt" runat="server" colspan="2" ><b>Taxable Amount</b></td><td id="tdtaxableamttext" runat="server" align="right" style="width:110px;"><asp:TextBox ID="txttaxableamount" runat="server" CssClass="DisableInputNumber" style="width:100px;"></asp:TextBox></td>
              </tr>
              <tr>
                <td id="tddiscounttax" runat="server" style="display:none;"><b>Discount</b></td><td id="tddiscounttaxper" runat="server" align="right" style="width:80px; display:none;" ><asp:TextBox ID="txtdiscounttaxper" runat="server" Width="70px" onblur="discountbill('taxable',this.id);" CssClass="inputnumber" style="display:none;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox></td><td id="tddiscounttaxamt" runat="server"  align="right" style="width:110px; display:none;"><asp:TextBox ID="txtdiscounttaxamt" runat="server" CssClass="DisableInputNumber" style="width:100px; display:none;"></asp:TextBox></td>
              </tr>
               <tr>
                <td id="tdnontaxableamt" runat="server" style="display:none;" colspan="2"><b>Non-Taxable Amount</b></td><td id="tdnontaxableamttext" runat="server"  align="right" style="width:110px; display:none;"><asp:TextBox ID="txtnontaxableamount" runat="server" CssClass="DisableInputNumber" style="width:100px; display:none;"></asp:TextBox></td>
              </tr>
              <tr>
                <td id="tddiscountnontax" runat="server" style="display:none;"><b>Discount</b></td><td id="tdnondiscountper" runat="server" align="right" style="width:80px; display:none;"><asp:TextBox ID="txtnondiscounttaxper" runat="server" Width="70px" onblur="discountbill('nontaxable',this.id);" CssClass="inputnumber" style="display:none;" OnKeyPress="return isNumberKey(this.ID,event);"></asp:TextBox></td><td id="tdnondiscounttaxamt" runat="server" colspan="2" align="right" style="width:110px; display:none;"><asp:TextBox ID="txtnondiscounttaxamt" runat="server" CssClass="DisableInputNumber" style="width:100px; display:none;"></asp:TextBox></td>
              </tr>
              <tr>
                <td id="tdservicechargeamt" runat="server" style="display:none;" colspan="2"><b>Service Charge Amount</b></td><td id="tdservicechargeamttext" runat="server" align="right" style="width:110px; display:none;"><asp:TextBox ID="txtservicechargeamt" runat="server" CssClass="DisableInputNumber" style="width:100px; display:none;"></asp:TextBox></td>
              </tr>
              <tr>
                <td id="tdtotalamount" runat="server" colspan="2"><b>Total Amount</b></td><td id="tdtotalamounttext" runat="server" align="right" style="width:110px;"><asp:TextBox ID="txttotalamount" runat="server" align="right" CssClass="DisableInputNumber" style="width:100px;"></asp:TextBox></td>
              </tr>
               <tr>
                <td id="tdservicetax" runat="server"><b>Service Tax %</b></td><td id="tdservicetaxtext" runat="server" align="right" style="width:80px;"><asp:TextBox ID="txtservicetaxpercent" runat="server" Width="70px" CssClass="DisableInputNumber"></asp:TextBox><asp:HiddenField ID="hidservicetaxpercent" runat="server" /></td><td align="right" style="width:110px;"><asp:TextBox ID="txtservicetax" runat="server" CssClass="DisableInputNumber" style="width:100px;"></asp:TextBox></td>
              </tr>
               <tr>
                <td id="tdpecess" runat="server"><b>P.E Cess %</b></td><td id="tdpecesstext" runat="server" align="right" style="width:80px;" ><asp:TextBox ID="txtpecesspercent" runat="server" Width="70px" CssClass="DisableInputNumber"></asp:TextBox><asp:HiddenField ID="hidpecesspercent" runat="server" /></td><td align="right" style="width:110px;"><asp:TextBox ID="txtpecess" runat="server" CssClass="DisableInputNumber" style="width:100px;"></asp:TextBox></td>
              </tr>
               <tr>
                <td id="tdhecess" runat="server"><b>H.E Cess %</b></td><td id="tdhecesstext" runat="server" align="right" style="width:80px;"><asp:TextBox ID="txthecesspercent" runat="server" Width="70px" CssClass="DisableInputNumber"></asp:TextBox><asp:HiddenField ID="hidhecesspercent" runat="server" /></td><td align="right" style="width:110px;"><asp:TextBox ID="txthecess" runat="server" CssClass="DisableInputNumber" style="width:100px;"></asp:TextBox></td>
              </tr>
               <tr>
                <td id="tdluxuarytax" runat="server"><b>Luxuary Tax %</b></td><td id="tdluxuarytaxtext" runat="server" align="right" style="width:80px;"><asp:TextBox ID="txtluxuarytaxpercent" runat="server" Width="70px" CssClass="DisableInputNumber"></asp:TextBox><asp:HiddenField ID="hidluxuarytaxpercent" runat="server" /></td><td align="right" style="width:110px;"><asp:TextBox ID="txtluxuarytax" runat="server" CssClass="DisableInputNumber" style="width:100px;"></asp:TextBox></td>
              </tr>
              <tr>
                <td id="tdroundofamt" runat="server"><b>Round Off Amount</b></td><td id="tdroundofamttext" runat="server" colspan="2" align="right"><asp:TextBox ID="txtroundofamt" runat="server" CssClass="DisableInputNumber" style="width:100px;"></asp:TextBox></td>
              </tr>
              <tr>
                <td id="tdgrandtotal" runat="server"><b>Grand Total</b></td><td id="tdgrandtotaltext" runat="server" colspan="2" align="right" ><asp:TextBox ID="txtgrandtotal" runat="server" CssClass="DisableInputNumber" style="width:100px;"></asp:TextBox></td>
              </tr>
            </table>
         </td>
       </tr>
    </table>
    <table style="width: 96%;">
        <tr>
            <td align="center">
                <asp:Button ID="btnSave" Text="Save" runat="server" CssClass="button"  OnClick="btnSave_Click"/>
                &nbsp;
                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CssClass="button" OnClick="btnCancel_Click" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
